package com.haohuo.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.atomic.AtomicLong;

/**
 * 日志跟踪ID生成
 *
 * @author jole
 *
 */
public class TraceIDUtil {

	private static final Logger LOGGER = LoggerFactory.getLogger(TraceIDUtil.class);

	private static final AtomicLong ATOMIC_LONG = new AtomicLong();

	static {
		long currentTimeMillis = System.currentTimeMillis();
		currentTimeMillis = currentTimeMillis % 1000000000;
		ATOMIC_LONG
				.set(currentTimeMillis);
		LOGGER.info("ATOMIC_LONG={}", ATOMIC_LONG.get());
	}

	public static long incrementAndGet() {
		return ATOMIC_LONG.incrementAndGet();
	}
}
